<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/head_latest.inc"%>
<link href="${baseURL}/themes/plugin/bootstrap/css/bootstrap.css"
	rel="stylesheet" type="text/css" />
	<link
	href="${baseURL}/themes/plugin/bootstrap-dialog/css/bootstrap-dialog.css"
	rel="stylesheet" type="text/css" />
<link href="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.css"
	rel="stylesheet" type="text/css" />
	<link href="${baseURL}/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css"/>
	<link href="${baseURL}/themes/blue/css/sys.css" rel="stylesheet"
		type="text/css" />
	<script src="${baseURL}/js/jquerys/jquery-1.12.1.min.js"
		type="text/javascript"></script>
	<script src="${baseURL}/themes/plugin/bootstrap/js/bootstrap.min.js"
		type="text/javascript"></script>
	<script
		src="${baseURL}/themes/plugin/bootstrap-dialog/js/bootstrap-dialog.js"
		type="text/javascript"></script>

	<script
		src="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.js"
		type="text/javascript"></script>
	<script
		src="${baseURL}/themes/plugin/bootstrapTable/locale/bootstrap-table-zh-CN.min.js"
		type="text/javascript"></script>
		<script src="${baseURL}/js/BT.js" type="text/javascript"></script>
<script src="${baseURL}/themes/plugin/ligerUI_latest/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="${baseURL}/themes/plugin/ligerUI_latest/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="${baseURL}/themes/plugin/ligerUI_latest/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
<script src="${baseURL}/themes/plugin/ligerUI_latest/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
<script src="${baseURL}/js/sdAppFrameworkCommon.js" type="text/javascript"></script>
<script src="${baseURL}/js/sdAppFrameworkAddressBook.js" type="text/javascript"></script>
<script src="${baseURL}/js/bootstrap-multiselect.js" type="text/javascript"></script>
<title>TemplateView list</title>
<style type="text/css">
#departName, #childsCount {
	color: #0066cc
}
.bootstrap-dialog-message{text-align:center;}
.bootstrap-dialog-message>p{text-align:center;}
.bootstrap-dialog-message>h4{text-align:center;}
.bootstrap-dialog-footer-buttons{text-align:center;}


</style>
</head>
<body class="FrameRightBg">
	<div class="FrameRight" id="FrameRightContent">
		<!-- 这里定义了转发进入的TAB对应的菜单ID，也是TAB的属性ID值 -->
		<input type="hidden" name="menuId" id="menuId" value="${param.menuId}" />
		<div id="mainsearch" style="width: 100%; margin-left: 0px">
		<%@ include file="/WEB-INF/jsp/module/view/new_selector_form.jsp"%>
			<form id="formsearch" method="post">
				<!-- <table>
					<tr>
						<td align="left" class="l-table-edit-td">名称:</td>
						<td align="left" class="l-table-edit-td"><input name="name" type="text" id="name"
							ltype="text" class="form-control" inputWidth="400" ltype="text" style="width: 250px"
							 /></td>
						<td align="left" class="l-table-edit-td"
							style="padding-left: 30px">
							<button type="button" id="btnSearch"
								class="l-button l-button-submit">
								<i class="fa fa-search"></i> 搜索
							</button>
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="reset" id="btnReset" class="l-button l-button-test">
								<i class="fa fa-exchange"></i> 重置
							</button>
						</td>
					</tr>
				</table> -->
				<div class="selector-form"></div>
			</form>
		</div>
		<div class="common-option" style="margin-top: 5px">
			<div class="inner">
				<button id="add" type="button" class="btn btn-icon"
					onclick="FF_AddClickEvent(this)">
					<i class="l-icon l-icon-a fa fa-plus-square-o"></i>新增
				</button>
				<button id="modify" type="button" class="btn btn-icon"
					onclick="FF_ModifyClickEvent(this)">
					<i class="l-icon l-icon-a fa fa-pencil-square-o"></i>修改
				</button>
				<button id="delete" type="button" class="btn btn-icon"
					onclick="FF_DeletedClickEvent(this)">
					<i class="l-icon l-icon-a fa fa-minus-square-o"></i>删除
				</button>
			</div>
		</div>
		<!-- 表格列表 -->
		<div class="common-table">
			<table id="maingrid" style="margin-left: 0px; width: 100%"></table>
		</div>


	</div>
	<script type="text/javascript">
	
	
	var baseUrl = '${baseURL}/report/template/templateview';
  function queryParams(params){
	  var data = [];
		if(selector != null){
			data = selector.getSelectorValue();
		}
	    return {
			pageNo: params.pageNumber,
			perPageSize: params.pageSize,
			searchParam: JSON.stringify(data)
		}
	}
  function initTable() {
  		$('#maingrid').bootstrapTable({
  			url:baseUrl+'list/listJSON.do?type=${param.type}',
  			method: 'post',
			contentType: "application/x-www-form-urlencoded",
       		sidePagination: "server",
       		queryParams: queryParams,
       		queryParamsType:"undenfied",
       	 dataField: "Rows",
         totalField:"Total",
         striped: true,                      //是否显示行间隔色
	        pageNumber:1,                       //初始化加载第一页，默认第一页
	     	pagination: true,
	        clickToSelect: true,                //是否启用点击选中行
            uniqueId: "id",                 //每一行的唯一标识，一般为主键列
       		columns: [{
                checkbox: true
            },{
                field: 'code',
                title: '编码',
	               formatter: function (value, row, index) {
	                   return value;  
	               }
            },{
                   field: 'name',
                   title: '名称',
   	               formatter: function (value, row, index) {
   	                   return value;  
   	               }
               }, {
                   field: 'url',
                   title: '路径',
                   formatter: function (value, Rows, index) {
                	   return value;
	               }
			   }],
			   onDblClickRow:function(row){
				   parent.f_addTab('TemplateView', "模板编辑", baseUrl+'edit/edit.do?menuId=${param.menuId}&id=' + row.id);
			   }
  		})
	}
  
   $(function () {
		initTable();
		$("#maingrid").css("text-align","center");
		}) 
	     //搜索事件
 	 $("#btnSearch").click(function(e){
 		var data = $("#name").val();
 		
 		FF_Reload(data);
 	 });

     //重置事件
     $("#btnReset").click(function(e){
     	var data = $("#code").val();
    	$("#code").val("");
    	FF_Reload("");
     });
   //工具条事件
     //新增事件
     function FF_AddClickEvent(btnItem){
    	 parent.f_addTab('TemplateView',"模板新增" , baseUrl+'edit/edit.do?menuId=${param.menuId}');
     }
      //修改事件
     function FF_ModifyClickEvent(btnItem){
     	var row = $('#maingrid').bootstrapTable('getSelections');
     	if (row.length == 0) { alert("请选择需要操作的行记录!"); return false;}
     	parent.f_addTab('TemplateView', "模板编辑", baseUrl+'edit/edit.do?menuId=${param.menuId}&id=' + row[0].id);
     }
    
      
     //删除事件
     function FF_DeletedClickEvent(btnItem){
    	 var selectedRow = $('#maingrid').bootstrapTable('getSelections');
     	if (!selectedRow || selectedRow.length <= 0) { alert("请选择需要操作的行记录!"); return false;}
     	var ids = '';
     	for(var index in selectedRow){
     		ids += selectedRow[0].id + ',';
     	}
     	ids = ids.substring(0,ids.length-1);
     	BT.showConfirm("删除","你确定删除所选信息吗？",function(){
    		 $.ajax({
					type: "post",
					url: baseUrl+"delete/delete.do",
					dataType : "json",
					data: {ids: ids},
					
				success: function(data){
					if(data.hasOk){
						BT.showSuccess('操作成功!',function(){
							FF_Reload("");
	    				});
					}else{
						BT.showError("操作失败!失败信息如下:\n" + data.message + "\n如您对以上信息有疑问，请联系管理人员!");
					}
				}
			 });
			});
     }
     //一个重新加载数据方法，该方法主要作为外部框架调用使用
     function FF_Reload(data){
    	 
    	var opt = {
    		        query:{
    		        	name:data,
    		        }
    		    };
    	$("#maingrid").bootstrapTable('refresh', opt);
   	  
     }
  	// 渲染选择器
 	var searchGrid = {
 		$element: $('#maingrid'),
 		load: function(){
 			this.$element.bootstrapTable('refresh');
 		}
 	}
  	var selector = $.initSelector(searchGrid, [
         	        		   {id:"name",name:"名称",value:"",isExtended:false,selectType:1}], null, []);
     

  </script>
</body>
  </html>
